﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;

namespace CommonManagement
{
    /// <summary>
    /// 用户控制器
    /// </summary>
    [RemoteService]
    [Area("commonManagement")]
    [Route("api/commonManagement/users")]
    public class UserController : AbpController, IUserAppService
    {
        private readonly IUserAppService _userAppService;

        public UserController(
            IUserAppService userAppService)
        {
            _userAppService = userAppService;
        }

        // 1.2.1 查询个人基本信息
        [Authorize]
        [HttpGet]
        [Route("getInfo")]
        public Task<UserGetInfoResponse> GetInfoAsync()
        {
            return _userAppService.GetInfoAsync();
        }

        // 1.2.2 修改个人基本信息
        [Authorize]
        [HttpPut]
        [Route("")]
        public Task<UserUpdateResponse> UpdateAsync(UserUpdateDto input)
        {
            return _userAppService.UpdateAsync(input);
        }

        // 1.2.3 修改用户密码
        [Authorize]
        [HttpPut]
        [Route("resetPwd")]
        public Task<UserResetPwdResponse> ResetPwdAsync(UserResetPwdDto input)
        {
            return _userAppService.ResetPwdAsync(input);
        }
    }
}